home *** CD-ROM | disk | FTP | other *** search
- Path: po.CWRU.Edu!mab22
- From: mab22@po.CWRU.Edu (Michael A. Balfour)
- Newsgroups: comp.lang.c
- Subject: Byte Orders and Char Sets?
- Date: 6 Mar 1996 19:56:49 GMT
- Organization: Case Western Reserve University, Cleveland, OH (USA)
- Message-ID: <4hkqm1$5dm@madeline.INS.CWRU.Edu>
- Reply-To: mab22@po.CWRU.Edu (Michael A. Balfour)
- NNTP-Posting-Host: nbsd.ins.cwru.edu
-
-
- Hi!
-
- In the hopes of writing some portable code, I'm trying to
- determine the byte order and character set that my program is
- compiled in. Does anybody have a faster or cleaner way than
- this:
-
- #define NativeCharSet() ((' '==0x40) ? EBCDIC_CHAR_SET : ASCII_CHAR_SET)
-
- static unsigned short int nativeIntTest=0x0001;
- static char *nativeIntTest2=(char *)&nativeIntTest;
- #define NativeByteOrder() ((nativeIntTest2[0]==0x00) ? LITTLE_ENDIAN : BIG_ENDIAN)
-
- (where the char sets and byte orders are also defined)
-
- Thank you very much,
-
- Mike Balfour
-